package com.example.fragmentdemo;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

/**
 * Created by zengfansheng on 2016/5/18.
 */
public abstract class BaseFragment extends Fragment {

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        Log.i(MainActivity.TAG, this.getClass().getSimpleName() + "----" + "1、onAttach()");

        Log.e(MainActivity.TAG, "BaseFragment: hashCode----" + getActivity().getClass().hashCode());
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Log.d(MainActivity.TAG, this.getClass().getSimpleName() + "----" + "2、onCreate(),savedInstanceState:" +
                (savedInstanceState == null));
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        Log.d(MainActivity.TAG, this.getClass().getSimpleName() + "----" + "3、onCreateView(),savedInstanceState:" +
                (savedInstanceState == null));
        return super.onCreateView(inflater, container, savedInstanceState);
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        Log.d(MainActivity.TAG, this.getClass().getSimpleName() + "----" + "4、onViewCreated(),savedInstanceState:" +
                (savedInstanceState == null));
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        Log.d(MainActivity.TAG, this.getClass().getSimpleName() + "----" + "5、onActivityCreated(),"
                + "savedInstanceState:" + (savedInstanceState == null));
    }

    @Override
    public void onViewStateRestored(@Nullable Bundle savedInstanceState) {
        super.onViewStateRestored(savedInstanceState);
        Log.d(MainActivity.TAG, this.getClass().getSimpleName() + "===========" + "onViewStateRestored,"
                + "savedInstanceState：" + (savedInstanceState == null));
    }

    @Override
    public void onStart() {
        super.onStart();
        Log.i(MainActivity.TAG, this.getClass().getSimpleName() + "----" + "6、onStart()");
    }

    @Override
    public void onResume() {
        super.onResume();
        Log.i(MainActivity.TAG, this.getClass().getSimpleName() + "----" + "7、onResume()");
    }

    @Override
    public void onPause() {
        super.onPause();
        Log.i(MainActivity.TAG, this.getClass().getSimpleName() + "----" + "8、onPause()");
    }

    @Override
    public void onStop() {
        super.onStop();
        Log.i(MainActivity.TAG, this.getClass().getSimpleName() + "----" + "9、onStop()");
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        Log.i(MainActivity.TAG, this.getClass().getSimpleName() + "----" + "10、onDestroyView()");
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        Log.i(MainActivity.TAG, this.getClass().getSimpleName() + "----" + "11、onDestroy()");
    }

    @Override
    public void onDetach() {
        super.onDetach();
        Log.i(MainActivity.TAG, this.getClass().getSimpleName() + "----" + "12、onDetach()");
    }

    @Override
    public void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        Log.w(MainActivity.TAG, this.getClass().getSimpleName() + "===========" + "onSaveInstanceState");
    }

    @Override
    public void onHiddenChanged(boolean hidden) {
        super.onHiddenChanged(hidden);
        Log.i(MainActivity.TAG, this.getClass().getSimpleName() + "===========" + "onHiddenChanged():" + hidden);
    }

}
